<template>
  <view class="rate-wrap">
    <rate-star @item="onItem" id="rateStar1" />
    <rate-star percent="56" width="20" height="22" id="rateStar2" />
    <rate-star percent="72" width="10" height="12" id="rateStar3" />
    <view>
      <rate-star
        :percent="scorePercent"
        width="10"
        height="12"
        id="rateStar4"
      />{{ scorePercent }}
    </view>
    <view v-if="list">
      <view v-for="(item, index) in list" :key="index">
        <rate-star
          :percent="scorePercent"
          width="10"
          height="12"
          :id="'rateStarIt' + index"
        />
      </view>
    </view>
    <button @tap="onTapRate">改变了</button>
  </view>
</template>

<script>
import rateStar from "../../../components/rate-star/rate-star.vue";
import Taro from "@tarojs/taro";
import { wx_login } from "../../../check";
export default {
  name: "test",
  data() {
    return {
      scorePercent: 0,
      list: [],
    };
  },
  onLoad() {
    // wx.enableAlertBeforeUnload({
    //   message: "询问对话框内容1",
    // });
  },
  components: { rateStar },
  methods: {
    onItem(index) {
      console.log(index);
    },
    onTapRate() {
      this.scorePercent = 65;
      this.list = [0, 1, 2];
      wx_login()
        .then(() => {
          var openId = Taro.getStorageSync("openId");
          console.log("登录成功", openId);
        })
        .catch((error) => {
          console.log("登录失败", error);
        });
    },
  },
  mounted() {},
};
</script>

<style lang="less">
@import url("../../rate-star.css");
</style>
